<template>
	<!-- 全真模拟-在线试卷【更多】 -->
	<view>
		<my-switch-navbar :activeTab.sync="activeTab" :tabName="tabName"></my-switch-navbar>
		<!-- <my-scroll-view scroll-y refresher-enabled :init="init"> -->
		<view class="container" v-show="activeTab === 0"><my-user-li v-for="(item, index) in list" :infoName="item.username" :thumbnail="item.avatar"></my-user-li></view>
		<view class="container" v-show="activeTab === 1">
			<my-user-li v-for="(item, index) in list" :infoNode="lastItem(item.time)" :infoName="item.username" :thumbnail="item.avatar ? item.avatar : '../../static/avatar.png'">
				<view slot="right" class="scoreTxt" :class="[item.score < 60 ? 'org' : 'gre']">{{ item.score }}</view>
			</my-user-li>
		</view>
		<!-- </my-scroll-view> -->
		<my-empty v-if="emptyFlase" emptyTit="暂无数据"></my-empty>
	</view>
</template>

<script>
import exam from '../../mixins/exam.js';
export default {
	mixins: [exam],
	data() {
		return {
			examId: 0, //ID
			tabName: ['未交卷', '已交卷'],
			list: [],
			activeTab: 0,
			emptyFlase:false
		};
	},
	onLoad({ examId }) {
		this.examId = examId;
		this.init();
	},
	watch: {
		activeTab(newValue, oldValue) {
			this.getPageData();
		}
	},
	computed: {
		lastItem() {
			return function(value) {
				if (value) {
					return '交卷时间：' + value;
				}
			};
		}
	},
	methods: {
		init() {
			this.list = [];
			return this.getPageData();
		},
		getPageData() {
			this.status = 'loading';
			const pageData = {
				examId: this.examId,
				type: this.activeTab + 1
			};
			return new Promise((resolve, reject) => {
				// 2已完成 3未完成
				this.request.get('/app/teacher/home/examStusProcess/' + pageData.examId + '/' + pageData.type).then(res => {
					this.list = res;
					this.emptyFlase=this.list.length>0?false:true
					resolve();
				});
			});
		}
	}
};
</script>
<style scoped lang="scss">
.scoreTxt{
	font-weight: 600;
}
.uni-swipe {
	margin-bottom: 20upx;
}
.uni-swipe .paper-item {
	margin-bottom: 0;
}
.uni-swipe {
	margin-bottom: 20 upx;
}
</style>
